﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GestionCamping
{
    public partial class Connexion : Form
    {
        private Accueil FormAccueil;

        public Connexion()
        {
            InitializeComponent();
            FormAccueil = new Accueil();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            using (BDDCampingEntities bdd = new BDDCampingEntities())
            {
                var requete = from Employe in bdd.Employe select Employe;

                List<Employe> listeEmploye = requete.ToList();

                for (int i = 0; i < listeEmploye.Count; i++)
                {
                    if (listeEmploye.ElementAt(i).Login.Equals(textBox1.Text))
                    {
                        if (listeEmploye.ElementAt(i).MDP.Equals(textBox2.Text))
                        {
                            if (listeEmploye.ElementAt(i).ID == 4)
                            {
                                MessageBox.Show("Administrateur");

                            }
                            else
                            {
                                MessageBox.Show("Employé");
                            }

                            FormAccueil.Show();
                            this.Hide();
                            break;

                        }
                        else
                        {
                            MessageBox.Show("Employé non reconnu par le système");
                        }

                    }

                }

            }
        }

        private void Connexion_Load(object sender, EventArgs e)
        {
            textBox1.Text = "Admin";
            textBox2.Text = "Admin";
        }
    }
}
